package com.ruoyi.heima.news.client;

import com.ruoyi.common.core.constant.ServiceNameConstants;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.heima.news.domain.News;
import com.ruoyi.heima.news.factory.NewsFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

@FeignClient(value = ServiceNameConstants.NEWS_SERVICE,path = "/news", fallbackFactory = NewsFallbackFactory.class)
public interface NewsClient {
    // 同步新增通知公告到新闻
    @PostMapping
    AjaxResult addNewsFromNotice(@RequestBody News news);

    // 同步修改通知公告到新闻
    @PutMapping
    AjaxResult updateNewsByNoticeId(@RequestBody News news);

    // 根据通知公告id查询新闻
    @GetMapping("/notice/{noticeId}")
    News selectNewsByNoticeId(@PathVariable("noticeId") Long noticeId);

    // 同步删除通知公告到新闻
    @DeleteMapping("/notice/{noticeIds}")
    Boolean deleteNewsFromNotice(@PathVariable("noticeIds") Long[] noticeIds);

    // 删除一周前更新的已删除状态新闻
    @DeleteMapping("/deleted")
    AjaxResult deletedOneWeekAgoNews();
}
